//
//  InformationViewController.m
//  CommunitySupermarketProiect
//
//  Created by 吕惠卿 on 2017/9/25.
//  Copyright © 2017年 吕惠卿. All rights reserved.
//
#define LineFrameY 109
#define LineFrameWidth self.view.frame.size.width/3
#define LineFrameHeight 2

#import "InformationViewController.h"
#import "MessageHeaderView.h"

@interface InformationViewController ()<UIScrollViewDelegate>


@property (nonatomic, strong)UIScrollView *rootScrollView;
@property (nonatomic, strong)UILabel *lineLabel;

@end

@implementation InformationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    WhiteColor;
    NAVIGATIONTITLE(@"消息");
    [self creatUI];
    
}
-(void)leftBtn{
    self.rootScrollView.contentOffset = CGPointMake(WIDTH * 0, 0);
    self.rootScrollView.backgroundColor = [UIColor redColor];
    self.lineLabel.frame = CGRectMake(WIDTH * 0, LineFrameY, LineFrameWidth, LineFrameHeight);
}
-(void)centerBtn{
    self.rootScrollView.backgroundColor = [UIColor yellowColor];
    self.rootScrollView.contentOffset = CGPointMake(WIDTH * 1, 0);
    self.lineLabel.frame = CGRectMake((WIDTH/3)*1 , LineFrameY, LineFrameWidth, LineFrameHeight);
}
-(void)rightBtn{
    self.rootScrollView.backgroundColor = [UIColor greenColor];
    self.rootScrollView.contentOffset = CGPointMake(WIDTH * 2, 0);
    self.lineLabel.frame = CGRectMake((WIDTH/3)*2, LineFrameY, LineFrameWidth, LineFrameHeight);
}
//滑动scrollerView代理
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    NSLog(@"%lf",scrollView.contentOffset.x);
    self.lineLabel.frame = CGRectMake( scrollView.contentOffset.x / 3
                                      , LineFrameY, LineFrameWidth, LineFrameHeight);
    
}
-(void)creatUI{
    MessageHeaderView *messVC = [[MessageHeaderView alloc]initWithFrame:CGRectMake(0, 64, WIDTH, 45)];
    [messVC.leftBtn setTitle:@"系统消息" forState:UIControlStateNormal];
    [messVC.centerBtn setTitle:@"交易通知" forState:UIControlStateNormal];
    [messVC.rightBtn setTitle:@"聊天信息" forState:UIControlStateNormal];
    [messVC.leftBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [messVC.centerBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [messVC.rightBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [messVC.leftBtn addTarget:self action:@selector(leftBtn) forControlEvents:UIControlEventTouchUpInside];
    [messVC.centerBtn addTarget:self action:@selector(centerBtn) forControlEvents:UIControlEventTouchUpInside];
    [messVC.rightBtn addTarget:self action:@selector(rightBtn) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:messVC];
    
    self.lineLabel = [[UILabel alloc]init];
    self.lineLabel.backgroundColor = NavColor;
    [self.view addSubview:self.lineLabel];
    self.lineLabel.frame = CGRectMake(WIDTH * 0, LineFrameY, LineFrameWidth, LineFrameHeight);
    
    
    self.rootScrollView = [[UIScrollView alloc]init];
    self.rootScrollView.delegate = self;
    // 如果不设置该属性，scrollView无法滑动（即使添加了超出控件大小的子视图依然不能滑动）
    self.rootScrollView.contentSize = CGSizeMake(WIDTH*3, HEIGHT-113);
    self.rootScrollView.pagingEnabled = YES; // 默认为NO，设置YES内容视图整页滚动
    self.rootScrollView.showsHorizontalScrollIndicator = NO; // 隐藏、显示滚动指示条  水平方向
    self.rootScrollView.showsVerticalScrollIndicator = NO; // 垂直方向
    [self.view addSubview:self.rootScrollView];
    [self.rootScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.lineLabel.mas_bottom).with.offset(2);
        make.bottom.equalTo(self.view.mas_bottom).with.offset(0);
        make.width.mas_equalTo(WIDTH);
    }];
    
//    SystemMessagesViewController *First = [[SystemMessagesViewController alloc]init];
//    ChatViewController *Second = [[ChatViewController alloc]init];
//    TransactionNoticeViewController *Third = [[TransactionNoticeViewController alloc]init];
////    NSArray *controllers=@[First,Second,Third];
//    

    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
